package com.mworld.galaxy.bull.entity.product;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class LinkId implements Serializable {
    private static final long serialVersionUID = 3316373702789172399L;

    private Category category;
    private Product product;

    @ManyToOne
    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @ManyToOne
    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Override
    public int hashCode() {
        int result = (category != null ? category.hashCode() : 0);
        result = 31 * result + (product != null ? product.hashCode() : 0);
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        LinkId link = (LinkId) obj;
        if (category != null ? !category.equals(link.category) : link.category != null) {
            return false;
        }
        if (product != null ? !product.equals(link.product) : link.product != null) {
            return false;
        }
        return true;
    }
}
